package work20241209.b;

/**
 * @author zdl
 * @date 2024/12/9
 */
public class Demo {
    public static void main(String[] args) {
        T t = new T();
        t.test(4);
        System.out.println(t.res(3));
        System.out.println();
        System.out.println(t.feiBo(6));
        System.out.println();
        System.out.println(t.peach(1));
    }
}

class T {
    public void test(int n) {
        if (n > 2) {
            test(n - 1);
        }
        System.out.println(n);
    }

    public int res(int n) {
        if (n == 1) {
            return 1;
        } else {
            return res(n - 1) * n;
        }
    }

    //斐波那契数
    public int feiBo(int n) {
        if (n >= 1) {
            if (n == 1 || n == 2) {
                return 1;
            } else {
                return feiBo(n - 1) + feiBo(n - 2);
            }
        } else {
            return -1;
        }
    }

    public int peach(int day) {
        if (day == 10) {//第十天 只有1个桃子
            return 1;
        } else if (day >= 1 && day <= 9) {
            return (peach(day + 1) + 1) * 2;
        } else {
            System.out.println("传值不对！");
            return -1;
        }
    }
}
